//
//  SQ_San_Cell.m
//  Hand-held_kitchen
//
//  Created by 张张烨 on 16/1/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SQ_San_Cell.h"
#import "ZongTouwenjian.pch"
#import "SANSANSANCollectionViewCell.h"
#import "SheQumodel.h"
#import "shequSanCellmobel.h"
@interface SQ_San_Cell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic,retain)UICollectionView *collectionView;
@property(nonatomic,retain)NSIndexPath *inddd;

@end
@implementation SQ_San_Cell
- (void)dealloc
{
    [_tupian release];
    [_zi release];
    [_moble release];
    [_wangzhi release];
    [_collectionView release];
    [_inddd release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        /**<  图片 */
        self.tupian = [[UIImageView alloc]init];
        _tupian.image = [UIImage imageNamed:@"我的1"];
        [self.contentView addSubview:_tupian];
        [_tupian release];
        
        
        self.zi = [[UILabel alloc]init];
        _zi.font = [UIFont systemFontOfSize:14* KUAN];
        [self.contentView addSubview:_zi];
        [_zi release];
        [self coll];
        //        self.arr = [[NSArray alloc]init];
        
    }
    return self;
}
// 传值重点 重写set方法

-(void)setMoble:(shequSanCellmobel *)moble
{
    if (_moble == moble) {
        return;
    }
    [_moble release];
    _moble = [moble retain];
    [_collectionView reloadData];
}

-(void)setWangzhi:(SheQuCollctionWangZhi *)wangzhi
{
    if (_wangzhi == wangzhi) {
       
    }
    [_wangzhi release];
    _wangzhi = [wangzhi retain];
    [_collectionView reloadData];
}

-(void)coll{
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    // cell大小
    layout.itemSize = CGSizeMake(100 * KUAN, 100 *GAO);
    // 行列间距
    layout.minimumLineSpacing = 5 * KUAN;
    layout.minimumInteritemSpacing = 1 *GAO;
    // 边界
    layout.sectionInset = UIEdgeInsetsMake(0, 10 * KUAN, 0, 10 * KUAN);
    // 滚动方向
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    
    // 创建过程类似tableView
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 30 *GAO, Width, 140 * GAO) collectionViewLayout:layout];
    _collectionView.backgroundColor = [UIColor whiteColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    [self.contentView addSubview:_collectionView];
  
    
    
    
    
    [_collectionView registerClass:[SANSANSANCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
    
}
/**<  coll item的个数 */
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    
    return self.moble.imageArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    SANSANSANCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

    
    
  /**<  图片 */

        [cell.touxiang sd_setImageWithURL:[NSURL URLWithString:self.moble.imageArray[indexPath.row]]];
   
    
    
    
    return cell;
    
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.delagate tiaotiao3:self.wangzhi.imageArray[indexPath.row]];
   
    
}












-(void)layoutSubviews
{
    self.zi.frame = CGRectMake(60 * KUAN, 5 *GAO, 200 * KUAN, 35 * GAO);
    self.tupian.frame = CGRectMake(25 * KUAN, 10 * GAO, 20 * KUAN, 20 *GAO);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
